package javagamecontroller.activities.controllers;

import java.util.Map;
import com.javagamecontroller.R;
import android.os.Vibrator;
import util.input.android.events.AndroidButtonEvent;


/**
 * A button manager to create a playstation controller.
 * @author Ben Schwab
 * 
 */
public class PlaystationButtonManager extends ButtonManager {

    //I don't think grid locatios are magic numbers.
    
    public PlaystationButtonManager (ControllerFrame c, Vibrator vibrator) {
        super(c, vibrator);
        setSelectButton(20);

    }

    @Override
    void initializeController () {
        Map<Integer, AndroidButton> buttonImageMap = getButtonImageMap();
        buttonImageMap.clear();
        Map<Integer, Integer> buttonIDMap = getButtonIdMap();

        // create buttons
        AndroidButton circleButton = new AndroidButton(R.drawable.button_o_np, R.drawable.button_o);
        AndroidButton squareButton =
                new AndroidButton(R.drawable.button_sq_np, R.drawable.button_s);
        AndroidButton triangleButton =
                new AndroidButton(R.drawable.button_triangle_np, R.drawable.button_t);
        AndroidButton xButton = new AndroidButton(R.drawable.button_x_np, R.drawable.button_x);
        AndroidButton upArrow = new AndroidButton(R.drawable.arrow_up_np, R.drawable.arrow_up);
        AndroidButton leftArrow =
                new AndroidButton(R.drawable.arrow_left_np, R.drawable.arrow_left);
        AndroidButton rightArrow =
                new AndroidButton(R.drawable.arrrow_right_np, R.drawable.arrow_right);
        AndroidButton downArrow =
                new AndroidButton(R.drawable.arrow_down_np, R.drawable.arrow_down);
        AndroidButton startButton =
                new AndroidButton(R.drawable.ps_button_start_np, R.drawable.ps_button_start);
        AndroidButton selectButton =
                new AndroidButton(R.drawable.ps_button_select_np, R.drawable.ps_button_select);

        // store buttons in map
        buttonImageMap.put(1, upArrow);
        buttonImageMap.put(6, leftArrow);
        buttonImageMap.put(8, rightArrow);
        buttonImageMap.put(13, downArrow);
        buttonImageMap.put(4, triangleButton);
        buttonImageMap.put(9, squareButton);
        buttonImageMap.put(11, circleButton);
        buttonImageMap.put(16, xButton);
        buttonImageMap.put(21, startButton);
        buttonImageMap.put(20, selectButton);

        // store button id's
        buttonIDMap.put(1, AndroidButtonEvent.Playstation.UP);
        buttonIDMap.put(6, AndroidButtonEvent.Playstation.LEFT);
        buttonIDMap.put(8, AndroidButtonEvent.Playstation.RIGHT);
        buttonIDMap.put(13, AndroidButtonEvent.Playstation.DOWN);
        buttonIDMap.put(4, AndroidButtonEvent.Playstation.TRIANGLE);
        buttonIDMap.put(9, AndroidButtonEvent.Playstation.SQUARE);
        buttonIDMap.put(11, AndroidButtonEvent.Playstation.CIRCLE);
        buttonIDMap.put(16, AndroidButtonEvent.Playstation.X);
        buttonIDMap.put(21, AndroidButtonEvent.Playstation.START);

    }

}
